package com.stu.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import com.stu.interceptor.JwtAuthInterceptor;
/**
 * @author zy
 * @date 2025/4/15
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private JwtAuthInterceptor jwtAuthInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtAuthInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/pro/**",
                        "/productCheck/**",
                        "/users/save",
                        "/users/login",// 只排除具体接口而不是整个/users/**
                        "/coupon/getAllCoupon",
                        "/static/**", // 静态资源
                        "/error" // 错误页面
                );
    }
}
